package com.jinsi.common;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;


@Configuration
public class WebConfig implements WebMvcConfigurer {


    @Autowired
    private LoginInterceptor loginInterceptor;

    //拦截器的配置类
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // 实例化登录拦截器，用于注册
        /***
         * 所有路径都被拦截  addPathPatterns("/**")
         * 允许通过   excludePathPatterns("/login", "/register")等等
         */
        registry
                .addInterceptor(loginInterceptor).addPathPatterns("/**")
                .excludePathPatterns(loginInterceptor.getUrls());
        WebMvcConfigurer.super.addInterceptors(registry);

    }



}
